<script setup lang="ts">
import {
  downloadFileFromUrl,
  downloadFileFromImageUrl,
  downloadFileFromBase64,
  downloadFileFromBlobPart,
} from '@/core/utils/download';
import imageBase64 from '../config/imageBase64';
</script>

<template>
  <PageCard title="下载文件">
    <el-button
      type="primary"
      @click="
        downloadFileFromUrl({
          source: 'https://github.com/nefe/number-precision/archive/refs/tags/1.6.0.zip',
          target: '_self',
        })
      "
    >
      根据文件地址下载文件
    </el-button>
    <el-button
      type="primary"
      @click="
        downloadFileFromImageUrl({
          source: 'https://foruda.gitee.com/avatar/1676932653039749289/854479_lafen_1578933953.png',
          fileName: 'lafen-logo.png',
        })
      "
    >
      根据地址下载图片
    </el-button>
    <el-button
      type="primary"
      @click="
        downloadFileFromBase64({
          source: imageBase64,
          fileName: 'lafen_image.png',
        })
      "
    >
      base64流下载
    </el-button>
    <el-button
      type="primary"
      @click="
        downloadFileFromBlobPart({
          source: 'text content download',
          fileName: 'test.txt',
        })
      "
    >
      Blob、BlobPart、字符串下载
    </el-button>
  </PageCard>
</template>
